
const {pathToRegexp} = require('path-to-regexp')
console.log(pathToRegexp);
let configUrl = '/wzy/:id/:name';
let keys = [];
regExp = pathToRegexp(configUrl,keys);
console.log(regExp, keys);

configUrl = configUrl.replace(/:([^\/]+)/g,function (){
    console.log(arguments[1]);
    keys.push(arguments[1]);
    return '([^\/]+)'
})


let reg = new RegExp(configUrl);
let requestUrl = '/wzy/1/2';
let [,...args] = requestUrl.match(reg);
let params = {};
keys.forEach((key ,i) => {
    params[key] = args[i]
})

console.log(params);